﻿@page "/device-list"
@using Blazor.Core;
@using Blazor.Localization
@using Blazor.ViewModels.DeviceList;
@inherits SoraniComponentBase<DeviceListViewModel>
@inject IStringLocalizer<DeviceListLocalization> Loc


@if (ViewModel is not null)
{
    <AntList DataSource="@ViewModel.Devices">
        <Header>
            @Loc[DeviceListLocalization.DeviceList]
        </Header>
        <ChildContent Context="item">
            <ListItem>
                <Space>
                    <SpaceItem>
                        @item.Description
                    </SpaceItem>
                    <SpaceItem>
                        @item.Id
                    </SpaceItem>
                    <SpaceItem>
                        <Button Type="ButtonType.Link" Icon="@IconType.Outline.Edit" Disabled="ViewModel.IsEditing" OnClick="() => ChangeClickHandler(item)"/>
                    </SpaceItem>
                    <SpaceItem>
                        <Button Type="ButtonType.Link" Icon="@IconType.Outline.Delete" Danger Disabled="ViewModel.IsEditing" OnClick="() => DeleteClickHandler(item)"/>
                    </SpaceItem>
                </Space>
            </ListItem>
        </ChildContent>
        <Footer>
            <Button Type="ButtonType.Primary" OnClick="NewClickHandler" Disabled="ViewModel.IsEditing">@CommonLoc[CommonLocalization.Add]</Button>
        </Footer>
    </AntList>
}
else
{
    <Empty/>
}